<?php

namespace App\Models\Chanjet;
use App\Models\Fee\FeeType;
use App\Models\Purchase\ExpenseVoucherInfoPay;
use Illuminate\Database\Eloquent\Model;

class TplusExpenseVoucherInfo extends Model
{
    protected $table = 'tplus_expense_voucher_info';
    public $timestamps = false;
    protected $primaryKey = 'id';
    protected $guarded = ['_token'];
    public function main()
    {
        return $this->belongsTo(TplusExpenseVoucher::class,'main_id','id');
    }
    public function fee_type(){
        return $this->hasOne(FeeType::class, 'id', function($query){
            $expense_code = explode('_',$query->expense_code);
            return $expense_code[2]??'';
        });
    }
    public function pay_info()
    {
        return $this->hasMany(ExpenseVoucherInfoPay::class,'expense_voucher_info_id','id');

    }
}
